package jm.data.structure.heap;

import jm.data.structure.tree.printer.BinaryTrees;

import java.util.Comparator;

/**
 * @Description 二叉堆测试
 * @date 2022/4/29 9:45
 */
public class BinaryHeapMain {

    public static void main(String[] args) {
        test3();
    }

    private static void test1(){
        BinaryHeap<Integer> heap = new BinaryHeap<>();
        Integer[] integers = {72,68,43,38,14,10,3,50,47,21};


        for (Integer integer : integers) {
            heap.add(integer);
        }
        BinaryTrees.println(heap);

//        heap.remove();
//        BinaryTrees.println(heap);
//
//        heap.remove();
//        BinaryTrees.println(heap);
//
//        heap.remove();
//        BinaryTrees.println(heap);
//
//        heap.replace(9);
//        BinaryTrees.println(heap);
    }

    private static void test2(){
        Integer[] integers = {72,68,43,38,14,10,3,50,47,21};
        BinaryHeap<Integer> heap = new BinaryHeap<>(integers);
        BinaryTrees.println(heap);
    }

    private static void test3(){
        Integer[] integers = {72,68,43,38,14,10,3,50,47,21};
        BinaryHeap<Integer> heap = new BinaryHeap<>(integers, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        BinaryTrees.println(heap);
    }
}
